$(document).ready(function() {
	$('#loginBtn').bind('click',login);
});

function login(){
	var userObj = $('#username');
	var username = $.trim(userObj.val());
	if(username.length == 0){
		alert('请输入用户名');
		userObj.focus();
		return;
	}
	var pwdObj = $('#password');
	var password = $.trim(pwdObj.val());
	if(password.length == 0){
		alert('请输入密码');
		pwdObj.focus();
		return;
	}
	var url = '/json?action=LOGIN_ACTION&LOGIN_NAME=' + username + '&PASSWORD=' + password;
	$.post(encodeURI(url),{},function(data){
		if(data.success){
			location.href = '/admin/index_frame.html?menu=index&tab=work_desktop';
		}
		else{
			alert(data.errors.errmsg);
		}
	},'json');
}
